package com.jt.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 广播模式fanout配置
 **/

@Configuration
public class RabbitmqConfig_fanout {
    public static final String FANOUT_EXCHANGE = "fanout_exchange_liushuhong";
    public static final String QUEUE1 = "QUEUE1";
    public static final String QUEUE2 = "QUEUE2";

    @Bean
    public Exchange exchange() {
        return ExchangeBuilder.fanoutExchange(FANOUT_EXCHANGE).durable(true).build();
    }

    @Bean
    public Queue queue1() {
        //创建一个队列队列，并指定队列的名字
        return new Queue(QUEUE1, true);
    }

    @Bean
    public Queue queue2() {
        //创建一个队列队列，并指定队列的名字
        return new Queue(QUEUE2, true);
    }


    @Bean
    public Binding setFanoutExchange1() {
     //fanout模式不指定routingkey
        return BindingBuilder.bind(queue1()).to(exchange()).with("").noargs();

    }

    @Bean
    public Binding setFanoutExchange2() {
        //fanout模式不指定routingkey
        return BindingBuilder.bind(queue2()).to(exchange()).with("").noargs();

    }
}
